<html>
<head>
<title></title>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript" src="log.js"></script>
<script type="text/javascript" src="map.js"></script>
<script type="text/javascript">
var map = null;

function load() {
	if (true) {

		ajaxRequest("map.json", function(json) {
			map = json2map(json);
		});

		return;
	}

	var players = [
		new Player("p1", "P1", "", ["a11"]),
		new Player("p2", "P2", "", ["a12"])
	];
	var areas = [
		new Area("a1",  "", "World",         0, 0, "", "", [], null, null),
		new Area("a11", "a1", "Europe",        0, 0, "", "", ["l1"], "p1", 1),
		new Area("a12", "a1", "North America", 0, 0, "", "", ["l2"], "p2", 1),
		new Area("a13", "a1", "South America", 0, 0, "", "", ["l2"], "p1", 1),
		new Area("a14", "a1", "Africa",        0, 0, "", "", ["l1"], "p2", 1),
		new Area("a15", "a1", "Asia",          0, 0, "", "", ["l1"], "p1", 1),
		new Area("a16", "a1", "Oceania",       0, 0, "", "", ["l2"], "p2", 1)
	];
	var links = [
		new Link("l1", "a11", "a12", 1),
		new Link("l2", "a12", "a11", 1)
	];
	map = new Map(players, areas, links);
}
function test() {
//	var playerA = new Player("idA", "nameA");
//	var planetA = new Planet("idA", "nameA", 0, 0, playerA);
//	map.addPlayer(playerA);
//	map.addPlanet(planetA);
//	playerA.addPlanet(planetA);
//	planetA.setOwner(playerA);

//	var playerB = new Player("idB", "nameB");
//	var planetB = new Planet("idB", "nameB", 0, 0, playerB);
//	map.addPlayer(playerB);
//	map.addPlanet(planetB);
//	playerB.addPlanet(planetB);
//	planetB.setOwner(playerB);

	if (!map) {
		setTimeout(function() { test(); }, 50);
		return;
	}

	addlog("1 "+ map.getPlayer(0));
	addlog("2 "+ map.getPlayerById("p1"));

	addlog("3 "+ map.getArea(0));
	addlog("4 "+ map.getAreaById("a11"));
	addlog("5 "+ map.searchAreasByName("Europe"));
	addlog("6 "+ map.searchAreasByOwner("p1"));
}
</script>

<style type="text/css">
</style>
</head>
<body onload="load(); test();">
<div id='log'></div>

<!--img src ="planets.gif" width="480" height="320" alt="Planets" usemap ="#planetmap" />

<map name="planetmap">
  <area shape="rect"   coords="0,0,82,126" href="sun.htm" alt="Sun" />
  <area shape="circle" coords="90,58,3"    href="mercur.htm" alt="Mercury" />
  <area shape="circle" coords="124,58,8"   href="venus.htm" alt="Venus" />
</map-->

</body>
</html>
